home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
window3a
/
palette3.frm
< prev
next >
Wrap
Text File
|
1999-09-23
|
4KB
|
149 lines
VERSION 5.00
Begin VB.Form Form1
Caption = "Windows Colours by oigres P"
ClientHeight = 4155
ClientLeft = 60
ClientTop = 345
ClientWidth = 6375
LinkTopic = "Form1"
ScaleHeight = 277
ScaleMode = 3 'Pixel
ScaleWidth = 425
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 3855
Left = 2400
ScaleHeight = 253
ScaleMode = 3 'Pixel
ScaleWidth = 45
TabIndex = 4
Top = 120
Width = 735
End
Begin VB.CommandButton Command5
Caption = "Randomize Element"
Height = 495
Left = 0
TabIndex = 3
Top = 720
Width = 1095
End
Begin VB.ListBox List1
Height = 2790
Left = 3480
TabIndex = 2
Top = 120
Width = 2655
End
Begin VB.CommandButton Command3
Caption = "Restore"
Height = 495
Left = 0
TabIndex = 1
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "Randomize All Colours"
Height = 495
Left = 0
TabIndex = 0
Top = 120
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Windows Colours by oigres P
'Email: oigres@postmaster.co.uk
'
'Adapted from MSDN :indented by indenter5
Const COLOR_BACKGROUND = 1
Const COLOR_ACTIVECAPTION = 2
Const COLOR_WINDOWFRAME = 6
Const clr As Integer = 255
Dim SavedColors(clr) As Long
Sub Command1_Click()
Dim i As Long
' Change all display elements:
ReDim NewColors(clr) As Long
ReDim IndexArray(clr) As Long
For i = 0 To clr
NewColors(i) = QBColor(Int(16 * Rnd))
IndexArray(i) = i
Next i
SetSysColors clr + 1, IndexArray(0), NewColors(0)
End Sub
Private Sub Command3_Click()
Dim i As Long
' Restore system colors:
ReDim IndexArray(clr) As Long
For i = 0 To clr
IndexArray(i) = i
Next i
SetSysColors clr + 1, IndexArray(0), SavedColors(0)
picupdate
End Sub
Private Sub Command5_Click()
If List1.ListIndex > -1 Then
SetSystemPaletteUse Form1.hdc, SYSPAL_NOSTATIC
mydc = GetDC(Form1.hwnd)
oldmode = SetBkMode(mydc, TRANSPARENT)
SetSysColors 1, List1.ListIndex, QBColor(Int(16 * Rnd))
SetBkMode mydc, oldmode
ReleaseDC Form1.hwnd, mydc
SetSystemPaletteUse Form1.hdc, SYSPAL_STATIC
picupdate
End If
End Sub
Sub Form_Load()
Dim i As Long
' Save current system colors:
For i = 0 To clr
SavedColors(i) = GetSysColor(i)
List1.AddItem i & ":" & Hex(SavedColors(i))
Next i
Show
picupdate 'draw colours into picbox
End Sub
Sub picupdate()
'set up pic display
Picture1.CurrentX = 0
Picture1.CurrentY = 0
i = 0
For Y = 0 To Picture1.ScaleHeight Step Picture1.ScaleHeight \ 24
Picture1.CurrentX = 0
Picture1.CurrentY = Y
Picture1.Print i
Picture1.Line (18, Y)-(Picture1.ScaleWidth, Y + 8), GetSysColor(i), BF
i = i + 1
Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
'set colours back to original then exit program correctly
'if you don't unload form then colours not restored
Command3.Value = True
Unload Me
Set Form1 = Nothing
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.ToolTipText = Hex(Picture1.Point(X, Y))
End Sub